package com.city.vodservice.controller;

import com.city.commonutils.Result;
import com.city.vodservice.service.VodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Cheng
 * Date: 2020/9/10
 * Time: 12:15
 * Description: No Description
 */
@RestController
@RequestMapping("/eduvod/video")
@CrossOrigin
public class VodController {
    //前端直接调用该接口上传视频到阿里云

    @Autowired
    private VodService vodService;

    @PostMapping("uploadAlyiVideo")
    public Result uploadAlyiVideo(MultipartFile file){
        String videoId = vodService.uploadVideoAly(file);
        return Result.ok().data("videoId",videoId);
    }

    @DeleteMapping("removeAlyVideo/{id}")
    public Result removeAlyVideo(@PathVariable String id){
        vodService.removeAlyVideoById(id);
        return Result.ok();
    }

    //删除课程时涉及到删除多个章节和很多小节和视频
    //删除多个视频接口
    //参数为多个视频id
    @DeleteMapping("delete-batch")
    public Result deleteBatch(@RequestParam("videoIdList") List<String> videoIdList){
        vodService.removeMoreAlyVideo(videoIdList);
        return Result.ok();
    }
}